
import {
  postSelectSeat, postallSeat,postAddSeat,postUpdateSeatstate,postDeleteSeat
} from "../../api/userinfo";
const seat = {
  state: {
    allseatInfo: {},
    seatInfo: {
    }, //座位信息
    addseatID: 0
  },

  mutations: {
    //保存作为基本信息
    SET_SEATINFO(state: any, value: any) {
      state.seatInfo = value;
    },
    SET_ALLSEAT(state: any, value: any) {
      state.allseatInfo = value;
    }
  },
  actions: {
    async SET_ALLSEAT(content: any) {
      return new Promise(async resolve => {
        await postallSeat().then((res) => {
          content.commit("SET_ALLSEAT", res.data)
          resolve(res)
        })
      })
    }
    ,
    async SET_SEATINFO(content: any, param: any) {
      return new Promise(async resolve => {
      await postSelectSeat({
        mid:param.mid,
        room_id: param.rid,
        session_id: param.sid,
        cinema_id:param.cid
      }).then((res) => {
        resolve(res.data)
        content.commit("SET_SEATINFO", res.data)
      })
    })
    },
    async SET_ADDSEAT(content: any, param: any) {
      return new Promise(async resolve => { 
        await postAddSeat(param).then((res)=>{
          resolve(res.data)
        })
    })
  },
  //修改座位状态id
  async SET_SEATSTATE(content: any, param: any) {
    return new Promise(async resolve => { 
      await postUpdateSeatstate(param).then((res)=>{
        console.log(res.data);
        resolve(res.data)
      })
  })
},
async SET_DELETESEAT(content: any, param: any) {
  return new Promise(async resolve => { 
    await postDeleteSeat(param).then((res)=>{
      console.log(res.data);
      resolve(res.data)
    })
})
},
}
};

export default seat;